﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DarkCRM.Helpers;
using System.Data;

namespace DarkCRM.Models
{
    public class CustomFollowupStatus : Entity
    {
        public int StatusID { get; set; }
        public string StatusDescription { get; set; }
        public int MemberID { get; set; }
        public bool IsDelete { get; set; }
        public DateTime CreateDate { get; set; }
        public CustomFollowupStatus()
        {
           
        }
        private static IList<CustomFollowupStatus> GetAllCustomFollowupStatus(int memberID)
        {
            IDictionary<string, object> par = new Dictionary<string, object>();
            par.Add("MemberID", memberID);
            DataTable dt = SqlHelper.ExecuteReader("GetCustomFollowupStatusByMemberID",par).Tables[0];

            EntityList<CustomFollowupStatus> customs = new EntityList<CustomFollowupStatus>();
            customs.Load(dt);
            return customs;
        }

        [DarkAjax.Utility.jQueryInvokeMethod(Url = "handlers/AjaxController.ashx", Method = "get", DataType = "json", Async = false)]
        public static ResultMessage GetFollowupStatus(int memberID)
        {
            var models = GetAllCustomFollowupStatus(memberID);
            var ps = models.Select(m => new { value = m.StatusID, text = m.StatusDescription });
            return new ResultMessage() { ErrorCode = 0, Lable = "success", Data = ps };
        }
    }
}